package com.guqiao.library.utils;

import android.content.Context;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;

/**
 * @author jiangyao
 * @desc 图片加载
 */
public class ImageLoader {

    public static <T extends ImageView> void display(Context context, Object path, T imageView) {
        Glide.with(context).load(path).into(imageView);
    }

    public static <T extends ImageView> void display(Context context, String url, T imageView) {
        Glide.with(context).load(url).into(imageView);
    }

    public static <T extends ImageView> void display(Context context, String url, RequestOptions options, T imageView) {
        Glide.with(context).load(url).apply(options).into(imageView);
    }

    public static void clearMemory(Context context) {
        if (context != null) {
            Glide.get(context.getApplicationContext()).clearMemory();
        }
    }

    public static void trimMemory(Context context, int level) {
        if (context != null) {
            Glide.get(context.getApplicationContext()).trimMemory(level);
        }
    }
}
